home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / helplib / create_help_windows.c next >
Encoding:
C/C++ Source or Header  |  1990-01-26  |  3.2 KB  |  118 lines

  1. /*
  2. ### create a help window ###
  3. */
  4.  
  5. #include <suntool/sunview.h>
  6. #include <suntool/textsw.h>
  7. #include <suntool/panel.h>
  8.  
  9. void create_help_windows()
  10. {
  11.     void help_quit_proc(),help_option_proc();
  12.     int i,ipanel_row=0,px,py;
  13.     extern Frame frame,help_frame;
  14.     extern Panel help_panel;
  15.     extern Textsw help_textsw;
  16.     extern Textsw_status help_status; 
  17.     extern Pixfont *boldfont;
  18.     extern Panel_item help_quit_item,help_option_item;
  19.     extern short help_panel_show;
  20.     extern int panel_colormap_on;
  21.     extern int help_option;
  22.     extern char string[],help_dir[];
  23.     
  24.     /* Turn on the flag */    
  25.     if(help_panel_show){
  26.         window_set(help_frame,WIN_SHOW,TRUE,0);    
  27.         return;
  28.     }
  29.     else
  30.         help_panel_show = 1;
  31.  
  32.     px = (int) window_get(frame,WIN_X) + (int) window_get(frame,WIN_WIDTH)/2;
  33.     py = (int) window_get(frame,WIN_Y) + (int) window_get(frame,WIN_HEIGHT) /2;
  34.     /* Create help frame */
  35.     help_frame = window_create(frame,FRAME,
  36.         FRAME_NO_CONFIRM,       TRUE,
  37.         FRAME_LABEL,    "help",
  38.         FRAME_SHOW_LABEL,       TRUE,
  39.         WIN_SHOW,       TRUE,
  40.         WIN_X,  px,
  41.         WIN_Y,  py,
  42.         WIN_HEIGHT, 400,
  43.         WIN_WIDTH, 650,
  44.         WIN_FONT, boldfont,
  45.         0);
  46.     if(help_frame == NULL) {
  47.         system_mess_proc(1,"No more windows. Clean up some windows to make room.");
  48.         help_panel_show = 0;
  49.         return;
  50.     }
  51.     /* Create Panel */
  52.     help_panel = window_create(help_frame, PANEL,
  53.         WIN_X, 0,
  54.         WIN_Y, 0,
  55.         WIN_FONT, boldfont,
  56.         0);
  57.     if(help_panel == NULL) {
  58.         system_mess_proc(1,"No more windows. Clean up some windows to make room.");
  59.         (void) destroy_help_windows();
  60.         return;
  61.     }
  62.     /* Create panel items */
  63.     help_quit_item= panel_create_item(help_panel, PANEL_BUTTON,
  64.         PANEL_LABEL_Y, ATTR_ROW(ipanel_row++),
  65.         PANEL_LABEL_X, ATTR_COL(0),
  66.         PANEL_LABEL_IMAGE, panel_button_image(help_panel, "Quit", 4, boldfont),
  67.         PANEL_NOTIFY_PROC, help_quit_proc,
  68.         0);
  69.     help_option_item= panel_create_item(help_panel, PANEL_CYCLE,
  70.         PANEL_LABEL_Y, ATTR_ROW(ipanel_row++),
  71.         PANEL_LABEL_X, ATTR_COL(0),
  72.         PANEL_DISPLAY_LEVEL, PANEL_CURRENT,
  73.         PANEL_LABEL_STRING, "Topic: ",
  74.         PANEL_CHOICE_STRINGS,
  75.             "About kaos",
  76.             "Mouse usage",
  77.             "Using Function Keys",
  78.             "Demonstration Examples",
  79.             "Getting familiar with Sunview panel items",
  80.             "kaos panels",
  81.             "Command line arguments",
  82.             "kaos data format",
  83.             "Batching jobs",
  84.             "Printing",
  85.             "Interrupt",
  86.             "Rescaling a box size",
  87.             "Description of built-in dynamical systems",
  88.             0,
  89.         PANEL_VALUE, help_option,
  90.         PANEL_NOTIFY_PROC, help_option_proc,
  91.         0);
  92.  
  93.     window_fit_height(help_panel);
  94.  
  95.     if(panel_colormap_on)
  96.         init_panel_colormap((Pixwin *) window_get(help_panel,WIN_PIXWIN),"help_panel_cms");
  97.  
  98.         sprintf(string,"%s/online_help.0",help_dir);
  99.         help_textsw = window_create(help_frame, TEXTSW,
  100.         0);
  101.     if(help_textsw == NULL) {
  102.         system_mess_proc(1,"No more windows. Clean up some windows to make room.");
  103.         (void) destroy_help_windows();
  104.         return;
  105.     }
  106.     window_set(help_textsw,
  107.                 TEXTSW_STATUS, &help_status,
  108.                 TEXTSW_FILE,string,
  109.                 TEXTSW_FIRST,0,
  110.                 0);
  111.         if(help_status == TEXTSW_STATUS_CANNOT_OPEN_INPUT){
  112.                 sprintf(string,"Help file (%s/%d) does not exist!\n",help_dir,help_option);
  113.                 system_mess_proc(1,string);
  114.         }       
  115.     if(panel_colormap_on)
  116.         init_panel_colormap((Pixwin *) window_get(help_textsw,WIN_PIXWIN),"help_textsw_cms");
  117. }
  118.